package com.ticket.web.controller.yanchu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ticket.common.annotation.Log;
import com.ticket.common.core.controller.BaseController;
import com.ticket.common.core.domain.AjaxResult;
import com.ticket.common.enums.BusinessType;
import com.ticket.system.domain.TYanchuReservedSeats;
import com.ticket.system.service.ITYanchuReservedSeatsService;
import com.ticket.common.utils.poi.ExcelUtil;
import com.ticket.common.core.page.TableDataInfo;

/**
 * 演出预留座Controller
 * 
 * @author ruoyi
 * @date 2023-10-17
 */
@Api(description = "演出预留座")
@RestController
@RequestMapping("/system/seats")
public class TYanchuReservedSeatsController extends BaseController
{
    @Autowired
    private ITYanchuReservedSeatsService tYanchuReservedSeatsService;


    @ApiOperation("查询演出预留座列表")
    @PreAuthorize("@ss.hasPermi('system:seats:list')")
    @GetMapping("/list")
    public TableDataInfo list(TYanchuReservedSeats tYanchuReservedSeats)
    {
        tYanchuReservedSeats.setOperaId(getOperaId());
        startPage();
        List<TYanchuReservedSeats> list = tYanchuReservedSeatsService.selectTYanchuReservedSeatsList(tYanchuReservedSeats);
        return getDataTable(list);
    }

    /**
     * 导出演出预留座列表
     */
    @PreAuthorize("@ss.hasPermi('system:seats:export')")
    @Log(title = "演出预留座", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TYanchuReservedSeats tYanchuReservedSeats)
    {
        List<TYanchuReservedSeats> list = tYanchuReservedSeatsService.selectTYanchuReservedSeatsList(tYanchuReservedSeats);
        ExcelUtil<TYanchuReservedSeats> util = new ExcelUtil<TYanchuReservedSeats>(TYanchuReservedSeats.class);
        util.exportExcel(response, list, "演出预留座数据");
    }


    @ApiOperation("获取演出预留座详细信息")
    @PreAuthorize("@ss.hasPermi('system:seats:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tYanchuReservedSeatsService.selectTYanchuReservedSeatsById(id));
    }

    @ApiOperation("新增演出预留座")
    @PreAuthorize("@ss.hasPermi('system:seats:add')")
    @Log(title = "演出预留座", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Validated TYanchuReservedSeats tYanchuReservedSeats)
    {
        return toAjax(tYanchuReservedSeatsService.insertTYanchuReservedSeats(tYanchuReservedSeats));
    }

    @ApiOperation("修改演出预留座")
    @PreAuthorize("@ss.hasPermi('system:seats:edit')")
    @Log(title = "演出预留座", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Validated TYanchuReservedSeats tYanchuReservedSeats)
    {
        return toAjax(tYanchuReservedSeatsService.updateTYanchuReservedSeats(tYanchuReservedSeats));
    }

    /**
     * 删除演出预留座
     */
    @PreAuthorize("@ss.hasPermi('system:seats:remove')")
    @Log(title = "演出预留座", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(tYanchuReservedSeatsService.deleteTYanchuReservedSeatsById(id));
    }
}
